package com.ts.api.common.constant;


import com.gitee.apanlh.util.base.StringUtils;

/**
 * 业务异常枚举
 *
 * @author Pan
 */
public enum BizEnum {

    UPLOAD_IMG_SUFFIX_ERROR(502, "非法图片"),
    UPLOAD_ERROR(501, "上传错误"),
    API_KEY_CACHE_NULL(900, "获取缓存失败"),
    /** 空 */
    EMPTY(90000000, "非法空参数"),
    ROLLBACK(90000001, "回滚异常"),
    ERROR_PARAM(90000002, "非法参数"),

    /** 渠道相关 */
    CHANNEL_CODE_EMPTY(10000000, "渠道非法参数"),
    CHANNEL_CODE_ERROR(10000001, "未知渠道"),
    CHANNEL_DISABLE(10000002, "渠道状态异常"),

    /** 用户重复注册 */
    REGISTER_DUPLICATE(10000100, "重复注册"),
    /** 用户已存在 */
    REGISTER_HAS_EXIST(10000101, "用户已注册"),
    /** 注册字段长度不一致 */
    REGISTER_PARAM_SIZE(10000201, "注册非法参数"),
    /** 注册字段名称不一致 */
    REGISTER_ERROR_FIELD_VALUE(10000202, "注册非法字段值"),
    /** 注册字段id不一致 */
    REGISTER_PARAM_ID(10000203, "注册非法参数"),

    /** 短信发送失败 */
    SMS_NET_ERROR(10000300, "短信发送失败"),
    SMS_NET_STATUS_ERROR(10000301, "短信发送失败,状态异常"),
    /** 短信验证码已过期 */
    SMS_NOT_EXIST(10000302, "短信验证码已过期"),
    /** 请勿重复发送短信 */
    SMS_DUPLICATE(10000303, "请勿重复发送短信"),
    /** 短信发送过多 */
    SMS_SEND_MAX(10000304, "短信发送过多"),
    SMS_VALID_ERROR(10000305, "短信验证码错误,请重新输入"),
    SMS_EMPTY(10000306, "短信验证码为空"),

    /** 表单参数为空 */
    FORM_EMPTY(11000100, "非法表单空"),
    /** 表单中存在非法id */
    FORM_PARAM_ID(11000101, "非法表单2"),
    FORM_PARAM_ID2(11000102, "非法表单3"),
    FORM_PARAM_ID3(11000103, "非法表单4"),
    FORM_PARAM_ID4(11000104, "非法表单5"),
    /** 重复提交表单 */
    FORM_DUPLICATE(11000105, "重复提交表单"),
    /** 获取表单非法参数 */
    FORM_PARAM_ERROR(11000106, "获取表单列表失败,非法参数"),

    /** 贷超 */
    MARKET_EMPTY(12000100, "产品列表为空"),

    /** 流程异常 */
    FLOW_EMPTY(20000001, "流程空"),
    /** 流程异常 */
    FLOW_ERROR(20000002, "流程异常"),
    /** 流程配置空 */
    FLOW_CONFIG_EMPTY(21000001, "流程配置空"),

    USER_LOGIN_EMPTY(30000001, "请登录"),
    USER_TOKEN_EMPTY(30000002, "令牌空"),
    USER_TOKEN_ERROR(30000003, "非法授权"),
    USER_TOKEN_EXPIRE(30000004, "令牌过期"),
    USER_TOKEN_PARSE_ERROR(30000005, "令牌解析失败"),
    USER_TOKEN_DECRYPT_ERROR(30000006, "令牌校验失败"),

    MATCH_PRODUCT_EMPTY(40000100, "无匹配计划"),
    MATCH_USER_EMPTY(40000101, "非法匹配用户"),
    MATCH_ORG_EMPTY(40000201, "机构资质为空"),
    MATCH_DUPLICATE(40000301, "用户已匹配"),
    MATCH_APPLY_FLOW_ERROR(40000302, "非法进件流程"),

    /** 回调 */
    API_CALL_FLOW_EMPTY(50000001, "无业务数据"),
    API_CALL_FLOW_USER_EMPTY(50000002, "无用户数据"),
    API_CALL_ACCEPT_ORG_ERROR(50000003, "授权失败-机构原因"),
    API_CALL_ACCEPT_ERROR(50000004, "授权失败-出现异常错误"),
    API_CALL_ACCEPT_PLAN_TIME_ERROR(50000005, "授权失败-计划超时"),
    API_CALL_ACCEPT_PLAN_MAX_ERROR(50000006, "授权失败-计划超出"),
    API_CALL_ACCEPT_AMOUNT_MAX(50000007, "授权失败-机构原因3"),
    API_CALL_ACCEPT_APPLY_FIELD_ERROR(50000008, "授权失败-资质不符合"),
    API_CALL_ACCEPT_APPLY_PHONE_STATUS_ERROR(50000009, "授权失败-非法手机状态"),
    API_CALL_ACCEPT_PULL_APPLY_NOTICE_ERROR(50000010, "授权失败-获取客资失败"),
    ;

    private final Integer code;

    private final String msg;

    private BizEnum(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public Integer getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    public String format(Object... objects) {
        return StringUtils.format(this.msg, objects);
    }
}

